home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q33369 < prev    next >
Text File  |  1988-08-02  |  2KB  |  63 lines

  1. Q33369 Loop Optimizations Problems with Unsigned Chars
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.    When a program is compiled with loop optimization in C Version
  8. 5.10, the use of unsigned chars in for loops may cause optimization
  9. problems under certain circumstances.
  10.    You can avoid these problems by either rearranging your code or
  11. using unsigned short instead of unsigned char or by compiling without
  12. loop optimization.
  13.    Microsoft has confirmed this to be a problem in Version 5.10. We
  14. are researching this problem and will post new information as it
  15. becomes available.
  16.  
  17. More Information:
  18.    The following is a sample program:
  19.  
  20. #include <stdio.h>
  21.  
  22. void main()
  23. {
  24.                 unsigned char   aa,bb;
  25.                 unsigned char   array[2][5];
  26.                 unsigned char   *name = "STUFF";
  27.  
  28.         for (aa=0;aa<2;aa++) {
  29.                 name = "STUFF";
  30.                 for (bb=0;bb<5;bb++) {
  31.                         array[aa][bb] = *name;
  32.                         name++;
  33.                         }
  34.                 }
  35.  
  36.         for (aa=0;aa<2;aa++) {
  37.                 for (bb=0;bb<5;bb++) {
  38.                         putchar(array[aa][bb]);
  39.                         }
  40.                 putchar('\n');
  41.                 }
  42. }
  43.  
  44. >From the mixed code listing, there seems to be a problem with a
  45. temporary variable being initialized as a BYTE and accessed as a WORD.
  46. In the following fragment, PTR [bp-18] is variable in question.
  47.  
  48. ;|***   for (aa=0;aa<2;aa++) {
  49. ; Line 10
  50. *** 00000b   c6 46 fc 02      mov  BYTE PTR [bp-4],2        ;aa
  51. *** 00000f   c7 46 fe 0b 00   mov  WORD PTR [bp-2],OFFSET DGROUP:$SG166+5 ;name
  52. *** 000014   c6 46 ee 00      mov  BYTE PTR [bp-18],0
  53.                                         $L20002:
  54. ;|***           name = "STUFF";
  55. ;|***           for (bb=0;bb<5;bb++) {
  56. ; Line 12
  57. *** 000018   c6 46 fa 00      mov  BYTE PTR [bp-6],0       ;bb
  58. *** 00001c   8b 76 ee         mov  si,WORD PTR [bp-18]
  59.  
  60.  
  61. Keywords:  buglist5.10
  62. Updated  88/08/03 09:57
  63.